import Role, { type IView } from '../../../selector/role';
import { userTypePrefix, type Option } from '../../../../../types';
import ApprovalService from '../base/service';

class RoleService extends ApprovalService<Option> implements IView {
  prefix = userTypePrefix.role;

  get options(): Option[] {
    return this.panel?.role.options || [];
  }

  // options: Option[] = [];
  component = Role;
  value: Array<string | Option> = [];

  onShow() {
    if (this.options.length > 0) return;
    this.initMetaData();
  }

  async initMetaData() {
    await this.panel.role.initData();
    // this.options = this.panel.role.options;
  }

  initData(value: Option[] = []): void {
    this.value = value;
    this.updateProperties(value);
  }
}

export default RoleService;
